<template>
    <div>
        <el-row style="margin: 10px 20px 10px 10px;">
            <el-select v-model="childtype" placeholder="请选择" style="margin-left: 30px;" @change="changetype">
                <el-option   label="党费收缴" value="党费收缴"></el-option>
                <el-option   label="党费使用" value="党费使用"></el-option>
            </el-select>
        </el-row>
        <el-table  :data="dfRecodersTrue"  border  @cell-dblclick="dbshowdfRecoders"  :empty-text="showemptytext">
            <el-table-column  width="120" label="标识" align="center">
                <template slot-scope="scope">
                    <img class="default-image" :src="$store.state.images.wujiaoxing" style="width：45px;height:45px;"> 
                </template> 
            </el-table-column>
            <el-table-column   label="类型"  align="center" width="120"  >
                <template slot-scope="scope"><div>{{childtype}}</div></template>
            </el-table-column>
            <el-table-column prop="name" width="630" label="名称" :show-overflow-tooltip='true' sortable align="center"></el-table-column>
            <el-table-column prop="time" width="180" label="年份" :show-overflow-tooltip='true' sortable align="center"></el-table-column>
            <el-table-column align="right">
                <template slot="header" slot-scope="scope">
                    <el-button  size="mini"  @click="serchdfrecorder">查询</el-button>
                    <el-button  size="mini"  @click="adddfrecorde" v-show="showAddDfrecoder">新增</el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination @changed="showdfRecoderstrue" :recoder="dfRecoders"> </pagination>
        <dfrecoderadd ref='dfrecoderadd' v-on:editResult="serchdfrecorder"></dfrecoderadd>
    </div>
</template>
<script>
import {mapActions} from 'vuex';
    export default {
        props:{
            typeA:'',
            typeB:'',
        },
        data: () => ({
            typeBB:'',
            dfRecoders:[],
            dfRecodersTrue:[],
            childtype:'党费收缴',
            childtypes:[
                {name:'党费收缴'},
                {name:'党费使用'},
            ],
            offset:0,
            showAddDfrecoder:false,


            default_emptytext:"请点击右侧查询记录",
            showemptytext:'',
        }),
        components: {
            dfrecoderadd: function(resolve) {require(["./dfrecoderadd.vue"], resolve);},
        },
        mounted() {
            if(this.GetUser()==false){
                this.$router.push("/");
            }
            this.GetActiveDwId_DzbId();
            if(this.$store.state.Dw_DzbID.dwid==-1 && this.$store.state.Dw_DzbID.dzbid==-1 && this.$store.state.user.operation==0){
                this.showAddDfrecoder = true;
            }
            else{
                this.showAddDfrecoder = false;
            }
            this.typeBB=this.typeB+'-'+this.childtype;
            this.$emit('gettab',this.typeBB);
        },
        methods: {
            ...mapActions(['GetUser','GetZbById','GetActiveDwId_DzbId']),
            dbshowdfRecoders(row, column, cell, event)//双击获取指定的文件
            {
                this.$emit('dbshowdfRecoder',row.recoder,row.time-0);
            },
            showdfRecoderstrue(showrecoders,offset){
                this.dfRecodersTrue=showrecoders;
                this.offset=offset;
            },
            indexbf(index){return index+this.offset+1;},
            changetype(type){
                this.typeBB=this.typeB+'-'+this.childtype;
                this.$emit('gettab',this.typeBB);
                this.serchdfrecorder();
            },
            serchdfrecorder(){
                let _this=this;
                this.dfRecoders=[];
                let postdata={
                    type:"getrecoder",
                    split:JSON.stringify({
                        dwid:-1,
                        dzbid:-1,
                        typeA:_this.typeA,
                        typeB:_this.typeBB,
                     })
                    
                }
                this.$Common.AjaxPost(postdata,true)
                .then(function(e){
                    if(e.FileRecods.length==0){
                        _this.showemptytext='没有找到记录';
                        setTimeout(() => {
                            _this.showemptytext=_this.default_emptytext;
                        }, 1000);
                    }
                    else{
                        _this.dfRecoders=e.FileRecods;
                    }
                    _this.$emit('serchrecorder',e.FileRecods);
                }).catch(function(reason) {
                    console.log('catch:', reason);
                });
            },
            adddfrecorde(){
                this.$refs.dfrecoderadd.$data.detailsVisible = true;
                this.$refs.dfrecoderadd.$data.needZk = true;
                this.$refs.dfrecoderadd.$data.title = '新增'+this.typeB;
                this.$refs.dfrecoderadd.$data.rowdata.typea=this.typeA;
                this.$refs.dfrecoderadd.$data.rowdata.typeb=this.typeBB;
            },
        },
    }
</script>

<style scoped>

</style>